﻿@using SmartSiteManagementSystem.Models.Admin;

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    ViewBag.BodyClass = "easyui-layout";
    AdminUserInfo adminUser = ViewBag.adminUser;
}
<div class="easyui-panel" style="padding:5px;">
    <table class="gou-formTable" align="center" style="align-content:center;">
        <tbody>
            <tr>

                <td align="center" class="" style="width:160px;" colspan="2">
                    <input id="AdminUserId" type="hidden" value="@adminUser.AdminUserId" />
                为了您账户的安全，请定期修改密码哦！</td>
            </tr>

            <tr>
                <td align="right" class="gou-formTable-title">旧密码：</td>
                <td align="left" class="">
                    <input id="UserPwd" name="UserPwd" type="password" value="" />
                </td>
            </tr>

            <tr>
                <td align="right" class="gou-formTable-title">新密码：</td>
                <td align="left" class="">
                    <input id="NewPwd" name="NewPwd" type="password" value="" />
                </td>
            </tr>

            <tr>
                <td align="right" class="gou-formTable-title">再次确认新密码：</td>
                <td align="left" class="">
                    <input id="NewPwd2" name="NewPwd2" type="password" value="" />
                </td>
            </tr>

            <tr>
                <td colspan="2" align="center">
                    <a href="javascript:void(0)" id="hfSave" class="easyui-linkbutton" iconcls="icon-save" onclick="SaveAdminUser();" style="width:150px;height:32px">保存</a>
                </td>
            </tr>
        </tbody>
    </table>

</div>



<script type="text/javascript">

    //保存
    function SaveAdminUser() {

        //验证必选项******************************************************************
        var AdminUserId = $("#AdminUserId").val();

        var UserPwd = $("#UserPwd").val();
        
        var NewPwd = $("#NewPwd").val();
        var NewPwd2 = $("#NewPwd2").val();
     

        if (UserPwd == "") {
            $.messager.alert('提示', '请输入旧密码!');
            return false;
        }
        if (NewPwd == "") {
            $.messager.alert('提示', '请输入新密码!');
            return false;
        }

        if (NewPwd2 == "") {
            $.messager.alert('提示', '请输入确认密码!');
            return false;
        }
        if (NewPwd != NewPwd2) {
            $.messager.alert('提示', '确认密码输入不一致!');
            return false;
        }
        if (NewPwd == UserPwd) {
            $.messager.alert('提示', '新密码与旧密码相同!');
            return false;
        }
        var param = { AdminUserId: AdminUserId, UserPwd: UserPwd, NewPwd: NewPwd, NewPwd2: NewPwd2};
        $.ajax({
            "type": "Post",
            "url": "DoEditPwd?t=" + new Date().getTime(),
            "dataType": "json",
            "data": param,
            "success": function (data) {
                if (data.IsSuccess) {
                    $.messager.alert('提示', data.Msg);
                }
                else {
                    $.messager.alert('提示', data.Msg);
                }
            }
        });
    }
</script>
